package io.read_file;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

/**
 * @author haomin
 * @date 2022/05/09 19:09
 **/
public class ReadFile1 {
    public static void main(String[] args) throws IOException {
        try (InputStream is = new FileInputStream("D:\\电影\\文件操作\\hello.txt")){
            byte[] b = new byte[10];
            // 以容量为10字节读取数据
            int n = is.read(b);
            System.out.println(n);
            System.out.println(Arrays.toString(b));
            // 一次读取一个字节
            n = is.read();
            System.out.println(n);
        }

        try(InputStream is = new FileInputStream("D:\\电影\\文件操作\\hello.txt")){
            byte[] buf = new byte[1024];
            int n = is.read(buf);
            System.out.println(n);
            System.out.println(Arrays.toString(buf));
        }
    }
}